/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package negocio;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Jorge
 */
@Entity
@Table(catalog = "mydb2", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Formula.findAll", query = "SELECT f FROM Formula f"),
    @NamedQuery(name = "Formula.findByIdformula", query = "SELECT f FROM Formula f WHERE f.idformula = :idformula")})
public class Formula implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer idformula;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "formulaIdformula")
    private List<Indicador> indicadorList;
    @JoinColumn(name = "idcomponentes_formula1", referencedColumnName = "idcomponentes_formula", nullable = false)
    @ManyToOne(optional = false)
    private ComponentesFormula idcomponentesFormula1;
    @JoinColumn(name = "idcomponentes_formula2", referencedColumnName = "idcomponentes_formula", nullable = false)
    @ManyToOne(optional = false)
    private ComponentesFormula idcomponentesFormula2;
    @JoinColumn(name = "operacion_idoperacion", referencedColumnName = "idoperacion", nullable = false)
    @ManyToOne(optional = false)
    private Operacion operacionIdoperacion;

    public Formula() {
    }

    public Formula(Integer idformula) {
        this.idformula = idformula;
    }

    public Integer getIdformula() {
        return idformula;
    }

    public void setIdformula(Integer idformula) {
        this.idformula = idformula;
    }

    @XmlTransient
    public List<Indicador> getIndicadorList() {
        return indicadorList;
    }

    public void setIndicadorList(List<Indicador> indicadorList) {
        this.indicadorList = indicadorList;
    }

    public ComponentesFormula getIdcomponentesFormula1() {
        return idcomponentesFormula1;
    }

    public void setIdcomponentesFormula1(ComponentesFormula idcomponentesFormula1) {
        this.idcomponentesFormula1 = idcomponentesFormula1;
    }

    public ComponentesFormula getIdcomponentesFormula2() {
        return idcomponentesFormula2;
    }

    public void setIdcomponentesFormula2(ComponentesFormula idcomponentesFormula2) {
        this.idcomponentesFormula2 = idcomponentesFormula2;
    }

    public Operacion getOperacionIdoperacion() {
        return operacionIdoperacion;
    }

    public void setOperacionIdoperacion(Operacion operacionIdoperacion) {
        this.operacionIdoperacion = operacionIdoperacion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idformula != null ? idformula.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Formula)) {
            return false;
        }
        Formula other = (Formula) object;
        if ((this.idformula == null && other.idformula != null) || (this.idformula != null && !this.idformula.equals(other.idformula))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "negocio.Formula[ idformula=" + idformula + " ]";
    }
    
}
